package cn.szzsi._web;

import cn.szzsi._webpc.BaseWebPcController;
import cn.szzsi.common.kit.BackUtil;
import cn.szzsi.common.model.zshop.AgentBalanceDetail;
import cn.szzsi.common.model.zshop.Member;
import com.jfinal.core.Controller;

import java.util.List;

public class AgentBalanceDetailController extends BaseWebPcController<AgentBalanceDetail>{

    public void listForm(){
        String phone=getLoginMember().getPhone();
        Member member=Member.dao.getByPhone(phone);
        setAttr("agentLevel",member.getAgentLevel());
        wapTemplatePath("agent_list.html");
    }

    public void getList(){
        String phone=getLoginMember().getPhone();
        Member member=Member.dao.getByPhone(phone);
        String agentId=member.getId();
        int pageNumber=getParaToInt("pageNumber", 1);//第几页,默认1
        int pageSize=getParaToInt("pageSize", 10);//每页的数量,默认10
        Integer level=getParaToInt("level");
        Integer start=(pageNumber-1)*pageSize;//从第几条开始显示
        String sql="SELECT abd.*,m.phone,m.realName FROM sys_agent_balance_detail abd LEFT JOIN sys_member m on abd.fromAgentId=m.id where abd.level="+level+" and abd.agentId='"+agentId+"' LIMIT "+start+","+pageSize+"";
        List<AgentBalanceDetail> agentBalanceDetailList=AgentBalanceDetail.dao.find(sql);
        renderJson(BackUtil.success("获取成功",agentBalanceDetailList));

    }
}
